<?php
//计算显示杨辉三角
    header("Content-Type: text/html; charset=utf-8");
    class s{

   	public function x($M=6){
   		$int = 1;
   		$arr = array();
   		$arr[1][1] = $int;
   		echo str_pad("&nbsp;",($M-1)*12,"&nbsp;");
			printf("%3d",$arr[1][1]);
			echo "<br/>";

			for ($i=2; $i<=$M; $i++) {
				for ($j=1; $j<=$i; $j++) {
					if ($j == 1) {
						echo str_pad("&nbsp;",($M+1-$i)*12,"&nbsp;");
					}
					　　$arr[$i][$j] = $arr[$i-1][$j-1] + $arr[$i-1][$j];
					    print_r($arr[$i][$j]);
					    echo "&nbsp;&nbsp;";
				}
				echo "<br/>";
   		}
    }
   }
   $c = new s();
   $c->x();
   ?>